package com.ming.controller;

import com.ming.message.Sender;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ming.exception.MyException;
import com.ming.properties.ProjectSetting;

/**
 * Created by yudm on 2016-10-23.
 */
@Controller
public class HelloController {

	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
    @Autowired
    private ProjectSetting projectSetting;

    @Autowired
    private Sender sender;
    @RequestMapping(value = "/" ,method = RequestMethod.GET)
    public String index(ModelMap modelMap) throws Exception{
//        modelMap.addAttribute("host","你好，"+name);
//        throw new Exception("测试异常");
        return "index";
    }


    @RequestMapping(value = "hello" ,method = RequestMethod.GET)
    public String hello(ModelMap modelMap) throws Exception{

//        modelMap.addAttribute("host","你好，"+name);
//        throw new Exception("测试异常");
//        logger.debug("参数name="+name);
//        sender.send(name);
        return "hello";
    }
    
    @RequestMapping(value = "json",method = RequestMethod.GET)
    public String json() throws MyException{
    	throw new MyException("发生错误2");
    }

    @RequestMapping("/login")
    public String login() {
        return "login";
    }
}
